<template>
  <div class="mapping-page">
    <!-- 头部盒子 -->
    <div class="header">
      <!-- 页面标题 -->
      <div class="title">
        <h4>页面管理</h4>
      </div>
    </div>

    <!-- table表格 -->
    <div class="table">
      <el-table
        height="500"
        :data="tableData1"
        style="width: 100%"
        row-key="id"
        border
        :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
      >
        <el-table-column prop="date" label="名称" width="180"></el-table-column>
        <el-table-column prop="name" label="标识" width="180"></el-table-column>
        <el-table-column prop="address" label="描述"></el-table-column>
        <el-table-column label="操作" width="220">
          <template v-slot="{ row }">
            <!-- <el-button v-if="row.type===1" size="mini" @click="add(row)">新增</el-button> -->

            <!-- <el-button size="mini" @click="edit">编辑</el-button> -->
            <!-- <el-button size="mini" type="danger">删除</el-button> -->
            <el-link
              :underline="false"
              style="margin-right: 5px"
              v-if="row.type === 1"
              type="primary"
              @click="add(row)"
              >新增</el-link
            >
            <el-link
              :underline="false"
              type="primary"
              style="margin-right: 5px"
              @click="edit"
              >编辑</el-link
            >
            <el-link :underline="false" type="primary">删除</el-link>
          </template>
        </el-table-column>
      </el-table>
    </div>

    <!-- 新增和编辑的对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="showDialog"
      width="35%"
      :before-close="handleCloseDialog"
    >
      <el-form label-width="80px" style="width: 80%">
        <el-form-item label="页面名称">
          <el-input></el-input>
        </el-form-item>
        <el-form-item label="页面标识">
          <el-input></el-input>
        </el-form-item>
        <el-form-item label="描述">
          <el-input></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary">保存</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <!-- <el-drawer title="页面列表" :visible.sync="showDrawer" :before-close="handleCloseDrawer"></el-drawer> -->
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData1: [
        {
          id: 1,
          date: "系统1",
          name: "系统1",
          address: "系统1",
          type: 1,
        },
        {
          id: 2,
          date: "系统2",
          name: "系统2",
          address: "系统2",
          type: 1,
          children: [
            {
              id: 31,
              date: "页面1",
              name: "页面1",
              address: "页面1",
              type: 0,
            },
            {
              id: 32,
              date: "页面2",
              name: "页面2",
              address: "页面2",
              type: 0,
            },
          ],
        },
        {
          id: 3,
          date: "系统3",
          name: "系统3",
          address: "系统3",
          hasChildren: true,
          type: 1,
        },
        {
          id: 4,
          date: "系统4",
          name: "系统4",
          address: "系统4",
          type: 1,
        },
      ],
      title: "新增页面",
      showDialog: false,
      // showDrawer: false
    };
  },

  methods: {
    add(row) {
      this.title = "新增页面";
      this.showDialog = true;
    },

    // 封装一个处理弹窗关闭的方法：需要关闭的时候调用，清楚表单的数据，初始化表单
    handleCloseDialog() {
      this.showDialog = false;
    },
    cancel() {
      this.showDialog = false;
    },
    edit() {
      this.title = "编辑页面";
      this.showDialog = true;
    },

    // viewPage() {
    //   this.showDrawer = true;
    // },
    // handleCloseDrawer() {
    //   this.showDrawer = false;
    // }
  },
};
</script>

<style lang="scss" scoped>
.mapping-page {
  background-color: #fff;
  padding: 0 50px 50px 50px;

  .header {
    display: flex;
    text-align: center;
    justify-content: space-between;
    align-items: center;
    // padding: 0 50px;

    .title {
      font-size: 20px;
    }

    .right {
      text-align: center;
      padding-top: 30px;
    }
  }

  .table {
  }

  .dialogBox {
    margin: 0 auto;
  }

  .drawerBox {
    // padding: 20px 40px;

    .rule {
    }
  }
}
</style>


